/**
 * 成品出库管理API接口
 * 包含成品出库单的查询、创建、更新、执行等相关接口
 */

import { http } from "@/common/service/service.js";

// 成品出库单相关接口
const finishedGoodsOutbound = {
  // 获取成品出库单列表
  getFinishedGoodsOutboundList(params) {
    return http.get("/wms/finished-goods/outbound/list", { params });
  },

  // 获取移动端成品出库单列表
  getMobileOutboundList(params) {
    return http.get("/wms/finished-goods/outbound/mobile/list", { params });
  },

  // 获取成品出库单详情
  getOutboundDetail(id) {
    return http.get(`/wms/finished-goods/outbound/detail/${id}`);
  },

  // 获取出库单明细列表
  getOutboundDetailList(outboundId) {
    return http.get(`/wms/finished-goods/outbound/detail/list/${outboundId}`);
  },
  //获取出库单明细库存列表
  getOutboundExecuteDetailList(outboundId) {
    return http.get(
      `/wms/finished-goods/outbound/detail/outbountList/${outboundId}`
    );
  },

  // 创建成品出库单
  createOutbound(data) {
    return http.post("/wms/finished-goods/outbound/add", data);
  },

  // 更新成品出库单
  updateOutbound(data) {
    return http.put("/wms/finished-goods/outbound/edit", data);
  },

  // 删除成品出库单
  deleteOutbound(id) {
    return http.delete(`/wms/finished-goods/outbound/delete`, { id });
  },

  // 批量删除成品出库单
  deleteBatch(ids) {
    return http.delete("/wms/finished-goods/outbound/deleteBatch", {
      ids: ids.join(","),
    });
  },

  // 执行出库
  executeOutbound(data) {
    return http.post("/wms/finished-goods/outbound/execute", data);
  },

  // 一键出库
  oneClickOutbound(id) {
    return http.post(`/wms/finished-goods/outbound/one-click-outbound/${id}`);
  },

  // 批量执行出库
  executeBatchOutbound(data) {
    return http.post("/wms/finished-goods/outbound/executeBatch", data);
  },

  // 获取仓库列表
  getWarehouseList(params) {
    return http.get("/wms/warehouse/listAll", { params });
  },

  // 获取库位列表
  getLocationList(warehouseId) {
    return http.get(`/wms/location/queryByWarehouseId`, {
      params: { warehouseId },
    });
  },

  // 通过订单创建出库单
  createOutboundByOrder(data) {
    return http.post("/wms/finished-goods/outbound/createByOrder", data);
  },

  // 导出出库单
  exportOutbound(params = {}) {
    return http.get("/wms/finished-goods/outbound/exportXls", params);
  },

  // 导入出库单
  importOutbound(params = {}) {
    return http.post("/wms/finished-goods/outbound/importExcel", params);
  },
};

// 导出所有接口方法
export const {
  getFinishedGoodsOutboundList,
  getMobileOutboundList,
  getOutboundDetail,
  getOutboundDetailList,
  getOutboundExecuteDetailList,
  createOutbound,
  updateOutbound,
  deleteOutbound,
  deleteBatch,
  executeOutbound,
  oneClickOutbound,
  executeBatchOutbound,
  createOutboundByOrder,
  exportOutbound,
  importOutbound,
  getWarehouseList,
  getLocationList,
} = finishedGoodsOutbound;

// 默认导出整个对象
export default finishedGoodsOutbound;
